#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;

double coeff[] = {1, -8, 28, -56, 70,
                    -56, 28, -8, 1};

double f(double x){  
    double value = 0.0;
    for (int i = 0; i <= 8; i++){
        value += coeff[i] * pow(x, i);
    }
    return value;
}

double g(double x){
    double value = coeff[0];
    for(int i = 1; i <= 8; i++){
        value = value * x + coeff[i];
    }
    return value;
}

double h(double x){
    return pow(x - 1, 8);
}

void print_data(double (*fun)(double), ofstream &out_file){
    if(out_file.is_open()){
        double delta = (1.01 - 0.99) / 100;
        for(int i = 0; i <= 100; i++){
            double x = 0.99 + delta * i;
            double y = fun(x);
            out_file << x << " " << y << endl;
        }
        out_file.close(); 
    }
    else{  
        cout << "Error creating file.";  
    }
}

int main(){

    ofstream f_out("f_data.txt");
    print_data(f, f_out);
    ofstream g_out("g_data.txt");
    print_data(g, g_out);
    ofstream h_out("h_data.txt");
    print_data(h, h_out);

    return 0;
}